/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package pl.edu.agh.student.logic.webapp;

import javax.ejb.Remove;
import javax.ejb.Stateless;
import org.jboss.seam.annotations.Destroy;
import org.jboss.seam.annotations.In;
import org.jboss.seam.annotations.Name;
import org.jboss.seam.annotations.Out;
import org.jboss.seam.security.Identity;
import pl.edu.agh.student.logic.service.UserServiceImpl;
import pl.edu.agh.student.model.User;

/**
 *
 * @author janburkot
 */
@Stateless
@Name("utilBean")
public class UtilBeanImpl implements UtilBean {
    
    @In(value="userService",create=true,required=false)
    @Out
    protected UserServiceImpl userService;
    @In
    Identity identity;
    
    public User getCurrentUser() {
        System.out.println("UtilBean currentUser");
        System.out.println(identity);
        User _user = userService.findByUsername(identity.getPrincipal().getName());
        System.out.println(_user);
        return _user;
    }

}
